<?php
/**
 * Created by PhpStorm.
 * User: liuhongchuan
 * Date: 2018/5/9
 * Time: 18:27
 */
namespace app\api\controller;

use app\common\controller\BaseApi;

/*anke 第二版接口 api*/
class TvApi extends  BaseApi
{
    public function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 获取TV盒子配置
     */
    public function getTvConfig()
    {
        $shop_id = input("shop_id/d", "");
        if (empty($shop_id)) {
            $this->ajax_error('','0003','无效的店铺ID');
        }
        $config = db("tvbox_config")->where(array("shop_id" => $shop_id))->field("bg_url, logo_url")->find();
        if (empty($config)) {
            $this->ajax_error('','0004','未找到店铺配置');
        }
        $http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
        $home_domain = $_SERVER['HTTP_HOST'];
        $data = array(
            "bg_url" => $http_type . $home_domain . $config['bg_url'],
            "logo_url" => $http_type .$home_domain . $config['bg_url']
        );
        $this->ajax_success($data);
    }
}